﻿using ManagementClinic.App.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace ManagementClinic.App.ViewModel.User
{
    public class UserViewModel : ViewModelBase, IDataErrorInfo
    {
        private int id;
        private string ma ;
        private string ten ;
        private string kyHieu;
        private string taiKhoan ;
        private string matKhau;
        private string ghiChu;

        public int Id
        {
            get { return id; }
            set
            {
                id = value;
                OnPropertyChanged("Id");
                
            }
        }
        public string Ma
        {
            get { return ma; }
            set
            {
                ma = value;
                OnPropertyChanged("Ma");
            }
        }
        public string Ten
        {
            get { return ten; }
            set
            {
                ten = value;
                OnPropertyChanged("Ten");
                
            }
        }
        public string KyHieu
        {
            get { return kyHieu; }
            set
            {
                kyHieu = value;
                OnPropertyChanged("KyHieu");
            }
        }
        public string TaiKhoan
        {
            get { return taiKhoan; }
            set
            {
                taiKhoan = value;
                OnPropertyChanged("TaiKhoan");
              
            }
        }
        public string MatKhau
        {
            get { return matKhau; }
            set
            {
                matKhau = value;
                OnPropertyChanged("MatKhau");
            }
        }
        public string GhiChu
        {
            get { return ghiChu; }
            set
            {
                ghiChu = value;
                OnPropertyChanged("GhiChu");
            }
        }
        private string error = string.Empty;
        public string Error
        {
            get { return error; }
        }
        public string this[string columnName]
        {
            get
            {
                error = string.Empty;
                switch (columnName)
                {
                    case "Ma":
                        if (string.IsNullOrWhiteSpace(Ma))
                            error = Const.Message.System.Validate.NotNull;
                        break;
                    case "KyHieu":
                        if(string.IsNullOrWhiteSpace(KyHieu))
                            error = Const.Message.System.Validate.NotNull;
                        break;
                    case "Ten":
                        if (string.IsNullOrWhiteSpace(Ten))
                            error = Const.Message.System.Validate.NotNull;
                        break;
                    case "TaiKhoan":
                        if (string.IsNullOrWhiteSpace(TaiKhoan))
                            error = Const.Message.System.Validate.NotNull;
                        break;
                    case "MatKhau":
                        if (string.IsNullOrWhiteSpace(MatKhau))
                            error = Const.Message.System.Validate.NotNull;
                        break;
                    default:
                        error=String.Empty;
                        break;
                }
                
                return error;

            }
        }
    }
}
